<script setup lang='ts'>
import { ref, onMounted } from 'vue';
import axios from '../utils/http';
import { numstr } from '../types/login';

const username = ref('');
const password = ref('');
const onSubmit = async(values: numstr) => {
    console.log('submit', values);
    const res = await axios.post('users/login',{
        username:username.value,
        userpwd:password.value
    });
    if(res.status === 200) {
        alert('登陆成功');
    }else{
        alert('登陆失败');
    }
   
};

onMounted( () => {
   
})
</script>

<template>
    <h3>登陆</h3>
    <van-form @submit="onSubmit">
        <van-cell-group inset>
            <van-field v-model="username" name="用户名" label="用户名" placeholder="用户名"
                :rules="[{ required: true, message: '请填写用户名' }]" />
            <van-field v-model="password" type="password" name="密码" label="密码" placeholder="密码"
                :rules="[{ required: true, message: '请填写密码' }]" />
        </van-cell-group>
        <div style="margin: 16px;">
            <van-button round block type="primary" native-type="submit">
                登陆
            </van-button>
        </div>
    </van-form>
</template>

<style></style>